package model;

import java.util.Random;

/**
 * this class manages the players and turns
 * @author HB
 *
 */
public class Game {
	/**-all players including currentplayer-*/
	private Player playerOne, playerTwo, currentPlayer;
	
	/**-generator to decide which player begins-*/
	private Random generator;
	
	/**
	 * constructor
	 */
	public Game(){
		this.generator = new Random(); 
	}
	
	/**
	 * set playerOne or playerTwo
	 * @param name
	 * @param player 1 for playerOne and 2 for playerTwo
	 */
	public void setPlayer(String name, int player){
		if(player == 0){
			playerOne = new Player(name);
		}else if(player == 1){
			playerTwo = new Player(name);
		}	
	}
	
	/**
	 * decide which player is begins
	 * @return currentPlayer
	 */
	public Player startingPlayer(){
		if(playerOne != null && playerTwo != null){
			int dice = this.generator.nextInt(10);
			if(dice % 2 == 0){
				currentPlayer = playerOne; 
			}else{
				currentPlayer = playerTwo;
			}
		}
		return currentPlayer;
	}
	
}
